/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React from 'react';
import type { ProColumns } from '@ant-design/pro-table';
import type { Columns } from './type';
import { Image, Typography, Space } from 'antd';

const { Text } = Typography;
export const FormColFormat = {
  labelCol: { span: 2 },
  wrapperCol: { span: 6 },
};

export const ModalFormColFormat = {
  labelCol: { span: 6 },
  wrapperCol: { span: 12 },
};

export const uploadType = ['s', 'inn', 'jdk'];

export const getColumns = (data: any) => {
  const columns: ProColumns[] = [
    {
      dataIndex: 'search',
      hideInTable: true,
      fieldProps: {
        placeholder: '输入账号或者流水号进行搜索',
      },
    },
    {
      title: '产品类型',
      dataIndex: 'kb_name',
      search: false,
      align: 'center',
      width: 100,
      ellipsis: true,
    },
    {
      title: '用户账号',
      dataIndex: 'user_id',
      search: false,
      align: 'center',
      width: 100,
      ellipsis: true,
    },
    {
      title: '支付流水号',
      dataIndex: 'trade_number',
      search: false,
      align: 'center',
      width: 100,
      ellipsis: true,
    },
    {
      title: '运单号',
      dataIndex: 'waybill_no',
      search: false,
      align: 'center',
      width: 100,
      ellipsis: true,
    },
    {
      title: '申请退款金额',
      dataIndex: 'money',
      search: false,
      align: 'center',
      width: 100,
      ellipsis: true,
      render: (_: any, record: Columns) => {
        const { money } = record;
        return money + '元';
      },
    },
    {
      title: '实退金额',
      dataIndex: 'real_money',
      search: false,
      hideInTable: data.status != 1,
      align: 'center',
      width: 100,
      ellipsis: true,
      render: (_: any, record: Columns) => {
        const { real_money } = record;
        return real_money + '元';
      },
    },
    {
      title: '情况说明',
      dataIndex: 'trans_desc',
      search: false,
      width: 100,
      align: 'center',
    },
    {
      title: '图片',
      dataIndex: 'pic',
      search: false,
      align: 'center',
      ellipsis: true,
      width: 100,
      render: (_: any, record: Columns) => {
        const { pic } = record;
        const pics: string[] = pic.split(';');
        return (
          <>{pics.length > 0 && pics.map((item) => <Image width={30} key={item} src={item} />)}</>
        );
      },
    },
    {
      title: '申请人',
      dataIndex: 'applicant',
      search: false,
      align: 'center',
      width: 100,
      ellipsis: true,
    },
    {
      title: '申请时间',
      dataIndex: 'create_time',
      search: false,
      align: 'center',
      width: 100,
      ellipsis: true,
    },
    {
      title: '状态',
      dataIndex: 'status',
      search: false,
      align: 'center',
      width: 100,
      render: (_: any, record: Columns) => {
        const { status, reason } = record;
        return (
          <div>
            {status == 0 ? (
              <Text type='warning'>待审核</Text>
            ) : status == 1 ? (
              <Text type='success'>已通过</Text>
            ) : status == 2 ? (
              <Space direction='vertical'>
                <Text type='danger'>已拒绝</Text>
                <Text>原因：{reason}</Text>
              </Space>
            ) : (
              ''
            )}
          </div>
        );
      },
    },
  ];
  return columns;
};
